package com.gjintel.auction.business.service.serviceImpl;

import com.gjintel.auction.business.dao.IAuctionCompareBidDao;
import com.gjintel.auction.business.model.AuctionCompareBid;
import com.gjintel.auction.business.service.IAuctionCompareBidService;
import com.gjintel.sdk.base.service.impl.BaseServiceImpl;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * Created by Administrator on 2017/11/17.
 */
@Service
public class AuctionCompareBidServiceImpl extends BaseServiceImpl implements IAuctionCompareBidService {
    @Resource
    private IAuctionCompareBidDao auctionCompareBidDao;

    @Override
    public List<AuctionCompareBid> findAllByAuctionIdAndBiddrId(String auctionId, String biddrId) {
        return auctionCompareBidDao.findAllByAuctionIdAndBiddrId(auctionId, biddrId);
    }

    @Override
    public List<AuctionCompareBid> findTopTenByAuctionId(String auctionId) {
        return auctionCompareBidDao.findTopTenByAuctionId(auctionId);
    }

    @Override
    public int countAllByAuctionId(String auctionId) {
        return auctionCompareBidDao.countAllByAuctionId(auctionId);
    }

    @Override
    public AuctionCompareBid findTopOneByAuctionId(String auctionId) {
        List<AuctionCompareBid> auctionCompareBidList = auctionCompareBidDao.findTopTenByAuctionId(auctionId);
        if (auctionCompareBidList == null || auctionCompareBidList.size() <= 0) {
            return null;
        }
        return auctionCompareBidList.get(0);
    }

    @Override
    public int countDistinctByAuctionId(String auctionId) {
        return auctionCompareBidDao.countDistinctByAuctionId(auctionId);
    }
}
